package org.bdware.doip.core.model.metadata;

import org.bdware.doip.core.model.digitalObject.DOWithMetadata;
import org.bdware.doip.core.model.digitalObject.DigitalObject;
import org.bdware.doip.core.model.digitalObject.DoType;

public class MetaDO extends DOWithMetadata {

    public MetaDO(String id){
        super(id,DoType.Metadata);
    }

    public static MetaDO fromDO(DigitalObject originalDO){
        MetaDO meta = new MetaDO(originalDO.id);
        if(originalDO.attributes == null || originalDO.attributes.get(METADATA) == null){
            return null;
        }
        meta.addAttribute(METADATA,originalDO.attributes.get(METADATA));
        return meta;
    }

    public static MetaDO fromDOWithMetadata(DOWithMetadata doWithMetadata){
        MetaDO meta = new MetaDO(doWithMetadata.id);
        meta.addAttribute(METADATA,doWithMetadata.getMetadata());
        return meta;
    }
}
